package com.wyd.studentboot.serviceImpl;

import com.wyd.studentboot.bean.SignIn;
import com.wyd.studentboot.mapper.SignInMapper;
import com.wyd.studentboot.service.SignInService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class SignInServiceImpl implements SignInService {
    @Autowired
    private SignInMapper dao;

    @Override
    public boolean getStatus(String student_id) {
        List<SignIn> list = dao.getStatus(student_id);
        if(list.isEmpty())return true;
        else return false;
    }

    /**
     *
     * @param sign
     * @return 0失败1成功2当天已签到
     */
    @Override
    public int add(SignIn sign) {
        if(getStatus(sign.getStudent_id()))
            return dao.add(sign.getStudent_id(),sign.getStatus());
        else return 2;
    }

    @Override
    public List<SignIn> history(String student_id) {
        return dao.history(student_id);
    }

}
